import requests


class DEParApi:
    # 添加部门
    @classmethod
    def add_emp(cls, add_emp_body, token):
        add_emp_url = "http://ihrm2-test.itheima.net/api/company/department"
        add_emp_header = {"Content-Type": "application/json", "Authorization": token}
        resp = requests.post(url=add_emp_url, headers=add_emp_header, json=add_emp_body)
        return resp

    # 查找部门
    @classmethod
    def query_emp(cls, token, query_emp_body):
        query_emp_url = "http://ihrm2-test.itheima.net/api/company/department/:id"
        query_header = {"Content-Type": "application/json", "Authorization": token}
        resp = requests.get(url=query_emp_url, headers=query_header, json=query_emp_body)
        return resp

    # 修改部门
    @classmethod
    def modify_emp(cls, token, modify_emp_body):
        modify_emp_url = "http://ihrm2-test.itheima.net/api/company/department/:id"
        modify_emp_header = {"Content-Type": "application/json", "Authorization": token}
        resp = requests.put(url=modify_emp_url, headers=modify_emp_header, json=modify_emp_body)
        return resp
